<html>
<head>
    <title>Admin for SOLR shortcuts</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
    <script type="text/javascript">

        var host = "http://localhost:8080/KiWi2"

        $(document).ready(function(){
            $.get(host+"/solrconfig/program",function(data){
                $('#program').val(data.value);
            });
        });

        function upload() {
            var data = $("#program").val();
            //upload
            $.ajax({
                type:"POST",
                contentType: "application/json",
                url: host+"/solrconfig/program?reindex=false",
                data: data,
                success: function() {
                    alert("program successfully loaded");
                },
                error: function(jXHR) {
                    alert(jXHR.statusText);
                }
            });
        }

        function uploadAndReindex() {
            var data = $("#program").val();
            //upload
            $.ajax({
                type:"POST",
                contentType: "application/json",
                url: host+"/solrconfig/program?reindex=true",
                data: data,
                success: function() {
                    alert("program successfully loaded");
                },
                error: function(jXHR) {
                    alert("Error: "+jXHR.responseText);
                }
            });
        }
    </script>
</head>
<body>
<i style="color:red;">A first example is presented beneath the EBNF</i>
<h1>Admin for SOLR shortcuts</h1>
<h2>Program:</h2>
<textarea id="program" rows="5" cols="100">Loading...</textarea>
<br>
<button onclick="upload()">Upload</button>
<button onclick="uploadAndReindex()">Upload and Reindex</button>
<h2>Sytax:</h2>
<h3>EBNF</h3>
Between tokens can be WSP? unless otherwise indicated<br>
<textarea rows="8" cols="100" readonly>
program    := rule+
rule       := name "=" path ";"
path       := uri ("?" uri)* "(" type ")"
name       := string
uri        := string
string     := {any character except wsp,"=","?",";","(",")"}
type       := "STRING"|"LONG"|"DOUBLE"|"TEXT"|"DATE"
wsp        := " "|"\t"|"\n"|"\r"
</textarea>
<!--
<textarea rows="14" cols="100" readonly>
program    := rule+
rule       := name '=' (choice | cluster) ';'
choice     := path ('|' path)*
path       := uri ('?' uri)*
cluster    := '[' definition (',' definition)* ']'
definition := bool ':' value | default
bool       := range
range      := number '<'path '<' number

uri        := name
value      := name
name       := {any utf-8 character}
number     := {long|integer|double|float}
wsp        := {0x20|0x09|0x0c|0x0a|0x0d}
</textarea>
-->
<h2>A first Example:</h2>
To send the HTTP request you need a HTTP Client like <a href="http://ditchnet.org/httpclient/">this</a>.<br><br>
<b>1. Create a resource</b><br>
Start the LMF framework under localhost:8080 and sent an HTTP POST to <code>http://localhost:8080/KiWi2/resource/1234</code>.<br><br>
<b>2. Put properties</b><br>
Send a HTTP PUT to <code>http://localhost:8080/KiWi2/resource/1234</code>. Use <code>Content-Type: application/json</code> and body:<br>
<code>
{"http://localhost:8080/KiWi2/resource/1234":<br>
&nbsp;&nbsp;{"http://www.kiwi-project.eu/kiwi/core/title":<br>
&nbsp;&nbsp;&nbsp;&nbsp;[{"type":"literal","value":"Das ist einTitel."],<br>
&nbsp;&nbsp;"http://www.kiwi-project.eu/kiwi/core/description":<br>
&nbsp;&nbsp;&nbsp;&nbsp;[{"type":"literal","value":"das ist eine Beschreibung"}],<br>
&nbsp;&nbsp;"http://www.kiwi-project.eu/kiwi/core/type":<br>
&nbsp;&nbsp;&nbsp;&nbsp;[{"type":"uri","value":"http://www.kiwi-project.eu/kiwi/core/ContentItem"}]<br>
&nbsp;&nbsp;}<br>
}
</code><br>
<i>Important:</i> If you use a host different to localhost:8080 you also have to change this in the body.<br><Br>
<b>3. Tag resource</b><br>
Send a HTTP POST to <code>http://localhost:8080/KiWi2/social/tagging/create?taggedItemUri=http://localhost:8080/KiWi2/resource/1234&tagLabel=Test</code>.
Change the value of url parameter tagLabel to "Hello World" and repeat the post.<br><br>
<b>4. Search</b><br>
Go to <code>http://localhost:8080/KiWi2/solr/ui/index.html</code> and search for all (<code>*:*</code>). The added resource is returned.<br>
<i>Important:</i> The search is configured to return only resources, that are typed with <code>http://www.kiwi-project.eu/kiwi/core/ContentItem</code>. To change
this, set the appendix variable in the solr/ui/index.html to empty string.
</body>
</html>